package com.chanel.iamframework.core.dao;

import com.chanel.iamframework.core.domain.Group;

public interface GroupDAO {
	
	/**
	 * Persist Group
	 * @param group entity
	 * @return The number of rows affected by the insert
	 */
	int createGroup(Group group);
	
	/**
	 * Get Group by id
	 * @param groupId Identity
	 * @return Group entity
	 */
	Group getGroup(Long groupId);
	
	/**
	 * Update Group by id
	 * @param group entity
	 * @return The number of rows affected by the insert
	 */
    int updateGroup(Group group);
    
    /**
     * Delete Group by id
     * @param groupId Identity
     * @return The number of rows affected by the insert
     */
    int deleteGroup(Long groupId);
    
	/**
     * Load Roles by GroupId into the returned {@link Group} instance.
     * @param groupId identity
     * @return {@link Group} instance with list of {@link com.chanel.iamframework.core.domain.Role}
     */
	Group loadRoles(Long groupId);

	/**
     * Load Users by GroupId into the returned {@link Group} instance.
     * @param groupId identity
     * @return {@link Group} instance with list of {@link com.chanel.iamframework.core.domain.User}
     */
	Group loadUsers(Long groupId);

	/**
	 * Load Applications by GroupId into the returned {@link Group} instance.
	 * @param groupId identity
	 * @return {@link Group} instance with list of {@link com.chanel.iamframework.core.domain.Application}
	 */
	Group loadApplications(Long groupId);

	/**
	 * Add Group, Role association
	 * @param groupId identity
	 * @param roleId identity
	 * @return The number of rows affected by the insert
	 */
	int addRole(Long groupId, Long roleId);

	/**
	 * Add Group, User association
	 * @param groupId identity
	 * @param userId identoty
	 * @return The number of rows affected by the insert
	 */
	int addUser(Long groupId, Long userId);

	/**
	 * Add Application, Group association
	 * @param applicationId identity
	 * @param groupId identity
	 * @return The number of rows affected by the insert
	 */
	int addApplication(Long applicationId, Long groupId);

	/**
	 * Delete Group, Role association
	 * @param groupId identity
	 * @param roleId identity
	 * @return The number of rows affected by the insert
	 */
	int deleteRole(Long groupId, Long roleId);

	/**
	 * Delete Group, User association
	 * @param groupId identity
	 * @param userId identity
	 * @return The number of rows affected by the insert
	 */
	int deleteUser(Long groupId, Long userId);

	/**
	 * Delete Application, Group association
	 * @param applicationId identity
	 * @param groupId identity
	 * @return The number of rows affected by the insert
	 */
	int deleteApplication(Long applicationId, Long groupId);
}